package com.example.nacos;

import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfPage;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.canvas.parser.PdfTextExtractor;

import java.io.File;
import java.io.IOException;

public class PDFReader {
    public static void main(String[] args) {
        try {
            File file = new File("D:\\log\\49f5b6fd896a4c8e87a31f8aa96c22fb.pdf");
            PdfReader pdfReader = new PdfReader(file.getAbsolutePath());
            PdfDocument pdf = new PdfDocument(pdfReader);
            PdfPage page = pdf.getPage(8);
            String text = PdfTextExtractor.getTextFromPage(page);
            System.out.println(text);
            pdf.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

